package com.xinqi.modules.prepare.prepare.convert;

import com.xinqi.common.base.utils.json.JSON;
import com.xinqi.common.mapstruct.CommonConvertConfig;
import com.xinqi.modules.prepare.prepare.domain.PrepareOperateLogEntity;
import com.xinqi.modules.prepare.prepare.dto.PrepareOperateLogExtend;
import com.xinqi.modules.prepare.prepare.dto.req.PrepareOperateLogCreateDTO;
import com.xinqi.modules.prepare.prepare.dto.req.PrepareOperateLogUpdateDTO;
import com.xinqi.modules.prepare.prepare.dto.rsp.PrepareOperateLogResultDTO;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.MappingTarget;

/**
 * 备课区操作记录表转换
 *
 * @author: system
 * @date: 2023/03/19
 */
@Mapper(config = CommonConvertConfig.class, imports = {JSON.class, PrepareOperateLogExtend.class})
public abstract class PrepareOperateLogConvert {
    public abstract PrepareOperateLogEntity create(PrepareOperateLogCreateDTO s);

    public abstract PrepareOperateLogEntity update(PrepareOperateLogUpdateDTO s, @MappingTarget PrepareOperateLogEntity t);

    public abstract PrepareOperateLogEntity update(PrepareOperateLogUpdateDTO s);

    @Mapping(target = "extend", expression = "java(JSON.parse(s.getExtend(), PrepareOperateLogExtend.class))")
    public abstract PrepareOperateLogResultDTO convert(PrepareOperateLogEntity s);
}
